import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

//Cleinte so utilizado para enviar respostas, nao precisa realizar checagens, etc
public class Client {
	static String ip = new String();
        public static void enviar(String pacote) {
                try {
                        // Retrieve the ServerName
                		ip = pacote.split("@")[2];
                        InetAddress serverAddr = InetAddress.getByName(ip);
                       
                        //Log.d("UDP", "C: Connecting...");
                        /* Create new UDP-Socket */
                        DatagramSocket socket = new DatagramSocket();
                 
                        /* Prepare some data to be sent. */
                        byte[] outData = (pacote).getBytes();
                        /* Create UDP-packet with
                         * data & destination(url+port) */
                        DatagramPacket packet = new DatagramPacket(outData, outData.length,     serverAddr, 1236);
                        //Log.d("UDP", "C: Sending: '" + new String(outData) + "'");
                        /* Send out the packet */
                        //espera ate o Android confirmar que recebeu o pacote
                        socket.send(packet);
                        System.out.println("pacote: " + pacote);
             			//se message == pacote entao o android recebeu o pacote e mandou ele de volta pode continuar
                        //Log.d("UDP", "C: Sent.");
                        //Log.d("UDP", "C: Done.");
                } catch (Exception e) {
                        //Log.e("UDP", "C: Error", e);
                }
        }
}